import {SettingInterface} from "../interface/SettingInterface";
import {defaultLocale} from "../../locale";
import {MENU} from "../types";

const initSettingState: SettingInterface = {
    locale: defaultLocale, // 默认语言国际化
    routerPath: [window.location.hash.split('#')[1] || '/home'], // 设置选中菜单
    loading: false
}
const settingReducer = (state: any = initSettingState, action: any) => {
    switch (action.type) {
        case MENU.LOCALE:
            return Object.assign({}, state, {locale: action.payload});
        case MENU.ROUTER_PATH:
            return Object.assign({}, state, {routerPath: action.path});
        case MENU.LOADING:
            return Object.assign({}, state, {loading: action.payload});
        default:
            return state;

    }

}
export default settingReducer;
